/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.uniminuto.Videominuto.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author JULIAN
 */
@Entity
@Table(name = "alquiler")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Alquiler.findAll", query = "SELECT a FROM Alquiler a"),
    @NamedQuery(name = "Alquiler.findByIdAlquiler", query = "SELECT a FROM Alquiler a WHERE a.idAlquiler = :idAlquiler"),
    @NamedQuery(name = "Alquiler.findByValorAlquiler", query = "SELECT a FROM Alquiler a WHERE a.valorAlquiler = :valorAlquiler"),
    @NamedQuery(name = "Alquiler.findByFecha", query = "SELECT a FROM Alquiler a WHERE a.fecha = :fecha"),
    @NamedQuery(name = "Alquiler.findByHora", query = "SELECT a FROM Alquiler a WHERE a.hora = :hora")})
public class Alquiler implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_alquiler")
    private Integer idAlquiler;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "valor_alquiler")
    private BigDecimal valorAlquiler;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @Basic(optional = false)
    @NotNull
    @Column(name = "hora")
    @Temporal(TemporalType.TIME)
    private Date hora;
    @JoinTable(name = "alquiler_video", joinColumns = {
        @JoinColumn(name = "id_alquiler", referencedColumnName = "id_alquiler")}, inverseJoinColumns = {
        @JoinColumn(name = "isan_vdi", referencedColumnName = "isan_video")})
    @ManyToMany
    private List<Video> videoList;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "alquiler")
    private TiempoAlquiler tiempoAlquiler;
    @JoinColumn(name = "id_cliente", referencedColumnName = "id_cliente")
    @ManyToOne(optional = false)
    private Cliente idCliente;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "alquiler")
    private ReproduccionAlquiler reproduccionAlquiler;

    public Alquiler() {
    }

    public Alquiler(Integer idAlquiler) {
        this.idAlquiler = idAlquiler;
    }

    public Alquiler(Integer idAlquiler, BigDecimal valorAlquiler, Date fecha, Date hora) {
        this.idAlquiler = idAlquiler;
        this.valorAlquiler = valorAlquiler;
        this.fecha = fecha;
        this.hora = hora;
    }

    public Integer getIdAlquiler() {
        return idAlquiler;
    }

    public void setIdAlquiler(Integer idAlquiler) {
        this.idAlquiler = idAlquiler;
    }

    public BigDecimal getValorAlquiler() {
        return valorAlquiler;
    }

    public void setValorAlquiler(BigDecimal valorAlquiler) {
        this.valorAlquiler = valorAlquiler;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public Date getHora() {
        return hora;
    }

    public void setHora(Date hora) {
        this.hora = hora;
    }

    @XmlTransient
    public List<Video> getVideoList() {
        return videoList;
    }

    public void setVideoList(List<Video> videoList) {
        this.videoList = videoList;
    }

    public TiempoAlquiler getTiempoAlquiler() {
        return tiempoAlquiler;
    }

    public void setTiempoAlquiler(TiempoAlquiler tiempoAlquiler) {
        this.tiempoAlquiler = tiempoAlquiler;
    }

    public Cliente getIdCliente() {
        return idCliente;
    }

    public void setIdCliente(Cliente idCliente) {
        this.idCliente = idCliente;
    }

    public ReproduccionAlquiler getReproduccionAlquiler() {
        return reproduccionAlquiler;
    }

    public void setReproduccionAlquiler(ReproduccionAlquiler reproduccionAlquiler) {
        this.reproduccionAlquiler = reproduccionAlquiler;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAlquiler != null ? idAlquiler.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Alquiler)) {
            return false;
        }
        Alquiler other = (Alquiler) object;
        if ((this.idAlquiler == null && other.idAlquiler != null) || (this.idAlquiler != null && !this.idAlquiler.equals(other.idAlquiler))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.edu.uniminuto.Videominuto.entities.Alquiler[ idAlquiler=" + idAlquiler + " ]";
    }
    
}
